/*------------------------------------------------------------------------------
 * PROJ : Prototype
 * NAME : sculove.spring.framework.exception.BizException.java
 *        
 * Copyright 2009 sculove All rights reserved
 *------------------------------------------------------------------------------
*/
package sculove.spring.framework.exception;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * <pre>
 * sculove.spring.framework.exception.BizException.java
 * 
 * Service단에서 Biz 메시지 전달하고, Exception 처리(rollbak함)
 * 
 * </pre>
 * @date : 2009. 12. 24. 오후 5:23:35
 * @version :
 * @author : sculove
 */
public class BizException extends RuntimeException {
	private final Log logger = LogFactory.getLog(this.getClass());
	private String viewName = null;
	private String messageCode;
	private String[] messageArguments;
	
	public BizException() {
	}
	
	/**
	 * MessageCode만 출력 (view는 현재뷰)
	 * @param messageCode
	 */
	public BizException(String messageCode) {
		this.messageCode = messageCode;
	}
	
	/**
	 * MessageCode와 argument 출력 (view는 현재뷰)
	 * @param messageCode
	 * @param messageArguments
	 */
	public BizException(String messageCode, String[] messageArguments) {
		this.messageCode = messageCode;
		this.messageArguments = messageArguments;
	}
	
	/**
	 * View로 이동 후, MessageCode만 출력
	 * @param messageCode
	 * @param viewName
	 */
	public BizException(String messageCode, String viewName) {
		this.messageCode = messageCode;
		this.viewName = viewName;
	}
	
	/**
	 * View로 이동 후, MessageCode와 argument 출력
	 * @param messageCode
	 * @param messageArguments
	 * @param viewName
	 */
	public BizException(String messageCode, String[] messageArguments, String viewName) {
		this.messageCode = messageCode;
		this.messageArguments = messageArguments;
		this.viewName = viewName;
	}
	
	@Override
	public void printStackTrace() {
		logger.error("", this);
	}

	public String getViewName() {
		return viewName;
	}

	public void setViewName(String viewName) {
		this.viewName = viewName;
	}

	public String getMessageCode() {
		return messageCode;
	}

	public void setMessageCode(String messageCode) {
		this.messageCode = messageCode;
	}

	public String[] getMessageArguments() {
		return messageArguments;
	}

	public void setMessageArguments(String[] messageArguments) {
		this.messageArguments = messageArguments;
	}
}
